﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PoshBoard.VisualDesigner.Controls
{
    /// <summary>
    /// Interaction logic for NewHyperLink.xaml
    /// </summary>
    public partial class NewHyperLink : UserControl, IPBComponentBase
    {
        public NewHyperLink()
        {
            InitializeComponent();
            Url = "www.PoshBoard.com";
        }

        public string text=string.Empty;
        public string url;

        public string Text
        {
            get
            {
                return text;
            }
            set
            {
                this.text = value;
                this.label1.Content = value;
            }
        }

        public string Url
        {
            get
            {
                return url;
            }
            set
            {
                this.url = value;
                if(this.text == string.Empty)
                    this.label1.Content = value;
            }
        }


        public string CommandBase { get { return "New-Hyperlink"; } }

        public string PSName { get; set; }

        public void BuildPSName(string parentName)
        {
            this.PSName = "$" + parentName + "_" + this.Name;
        }

        public string GetParameters()
        {
            string param = PSScriptHelper.GetCommonParameters(this);
                                   
            param += " -Url " + this.url;

            if(!string.IsNullOrEmpty(this.text))
                param += " -Text " + this.Text;

            return param;
        }

        public string GetConstructionScript()
        {
            string script = PSScriptHelper.BuildPSScript(this, this.Name, null);

            return script;
        }
    }
}
